package com.example.monitoringsystem.controller;

import com.example.monitoringsystem.bean.User;
import com.example.monitoringsystem.service.AdminService;
import com.example.monitoringsystem.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class RegisterController {
    @Autowired
    private AdminService adminService;

    @Autowired
    private UserService userService;

    @PostMapping(value = "register")
    @ResponseBody
    public void register(User user) {
        System.out.println(user);
        if (userService.findUserByAccount(user.getAccount()) == null) {
            adminService.register(user);
        } else {
            return;
        }
    }
}
